<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Pending Issues</title>
<link rel="stylesheet" href="boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="index.html" title="Safe Numerics">
<link rel="up" href="index.html" title="Safe Numerics">
<link rel="prev" href="rationale.html" title="Rationale and FAQ">
<link rel="next" href="acknowledgements.html" title="Acknowledgements">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img href="index.html" height="164px" src="pre-boost.jpg" alt="Library Documentation Index"></td>
<td><h2>Safe Numerics</h2></td>
</tr></table>
<div class="spirit-nav">
<a accesskey="p" href="rationale.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgements.html"><img src="images/next.png" alt="Next"></a>
</div>
<div class="section">
<div class="titlepage"><div><div><h2 class="title" style="clear: both">
<a name="safe_numerics.pending_issues"></a>Pending Issues</h2></div></div></div>
<div class="toc"><dl class="toc">
<dt><span class="section"><a href="pending_issues.html#idm462682896128"><code class="computeroutput">safe_base</code> Only Works for Scalar Types</a></span></dt>
<dt><span class="section"><a href="pending_issues.html#idm462682856528">Other Pending Issues</a></span></dt>
</dl></div>
<p>The library is under development. There are a number of issues still
  pending.</p>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="idm462682896128"></a><code class="computeroutput">safe_base</code> Only Works for Scalar Types</h3></div></div></div>
<p>The following is paraphrased from an issue raised by Andrzej
    Krzemieński as a <a href="https://github.com/robertramey/safe_numerics/issues/44" target="_top">github
    issue</a>. It touches upon fundamental ideas behind the library and
    how these ideas as the implementation of the library collided with
    reality.</p>
<p><span class="quote">“<span class="quote">In the current implementation safe&lt;T&gt; will only work
    with T being a C++ scalar type. Therefore making a general type
    requirements that say what operations are allowed is superfluous, and
    confusing (because it implies that safe&lt;&gt; is more
    generic.</span>”</span></p>
<p>When I started out, It became clear that I wanted "safe" types to
    look like "numeric" types. It also became clear pretty soon that there was
    going to be significant template meta-programming in the implementation.
    Normal type traits like std::is_integer are defined in the std namespace
    and one is discouraged from extending it. Also I needed some compile time
    "max" and "lowest" values. This lead me to base the design on
    std::numeric_limits. But std::numeric limits is inherently extensible to
    any "numeric" type. For example, money is a numeric type but not an
    intrinsic types. So it seemed that I needed to define a "numeric" concept
    which required that there be an implementation of std::numeric_limits for
    any type T - such as money in this case. When I'm doubt - I tend to think
    big.</p>
<p>For now though I'm not going to address it. For what it's worth, my
    preference would be to do something like: </p>
<pre class="programlisting"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> <span class="identifier">T</span><span class="special">&gt;</span>
<span class="keyword">struct</span> <span class="identifier">range</span> <span class="special">{</span>
    <span class="identifier">T</span> <span class="identifier">m_lowest</span><span class="special">;</span>
    <span class="identifier">T</span> <span class="identifier">m_highest</span><span class="special">;</span>
    <span class="comment">// default implementation</span>
    <span class="identifier">range</span><span class="special">(</span>
        <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">T</span> <span class="identifier">t_min</span><span class="special">,</span> 
        <span class="keyword">const</span> <span class="special">&amp;</span> <span class="identifier">T</span> <span class="identifier">t_max</span>
    <span class="special">)</span> <span class="special">:</span>
        <span class="identifier">m_lowest</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span><span class="special">::</span><span class="identifier">lowest</span><span class="special">(</span><span class="identifier">t_min</span><span class="special">)</span><span class="special">,</span>
        <span class="identifier">m_highest</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">numeric_limits</span><span class="special">&lt;</span><span class="identifier">T</span><span class="special">&gt;</span><span class="special">::</span><span class="identifier">max</span><span class="special">(</span><span class="identifier">t_max</span><span class="special">)</span>
    <span class="special">{</span><span class="special">}</span>
<span class="special">}</span><span class="special">;</span></pre>
<p>Then redeclare <code class="computeroutput">safe_base</code>, etc., accordingly.</p>
<p>Also note that for C++20, template value parameters are no longer
    restricted to integer primitive types but may be class types as well. This
    means the library maybe extended to user class types without changing the
    current template signatures.</p>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="idm462682856528"></a>Other Pending Issues</h3></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem"><p>The library is currently limited to integers. If there is
          interest, it could be extended to floats and possible to user
          defined types.</p></li>
<li class="listitem"><p>Although care has been taken to make the library portable, at
          least some parts of the implementation - particularly
          <code class="computeroutput">checked</code> integer arithmetic - depend upon two's
          complement representation of integers. Hence the library is probably
          not currently portable to all other possible C++ architectures.
          These days, this is unlikely to be a limitation in practice.
          Starting with C++20, integer arithmetic will be guaranteed by the
          C++ standard to be two's complement.</p></li>
<li class="listitem"><p><code class="computeroutput">std::common_type</code> is used in a variety of generic
          libraries, including std::chrono. Without a specialization for
          <code class="computeroutput">safe&lt;T&gt;</code>s one cannot use the safe wrappers e.g. as
          a representation for <code class="computeroutput">std::chrono::duration</code>.</p></li>
</ul></div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2012-2018 Robert Ramey<p><a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">Subject to Boost
      Software License</a></p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="rationale.html"><img src="images/prev.png" alt="Prev"></a><a accesskey="u" href="index.html"><img src="images/up.png" alt="Up"></a><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a><a accesskey="n" href="acknowledgements.html"><img src="images/next.png" alt="Next"></a>
</div>
</body>
</html>
